package com.example.medicine.Mapper.yian;

import com.example.medicine.Bean.yian.yian_shexiang;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface yian_shexiangMapper {
    @Select("select * from [yian_shexiang]")
    public List<yian_shexiang> getAll();

    @Select("select * from [yian_shexiang] where yianid=#{yianid}")
    public List<yian_shexiang> getByYianId(long yianid);

    @Insert("INSERT INTO [yian_shexiang](yianid, name, shese, shexing, shetai, taizhi, taise) " +
            "VALUES(#{yianid}, #{name}, #{shese}, #{shexing}, #{shetai}, #{taizhi}, #{taise})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertOne(yian_shexiang yian_shexiang);


    //批量插入
    @Insert({
            "<script>",
            "INSERT INTO [yian_shexiang](yianid, name, shese, shexing, shetai, taizhi, taise) VALUES ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.yianid}, #{item.name}, #{item.shese}, #{item.shexing}, #{item.shetai}, #{item.taizhi}, #{item.taise})",
            "</foreach>",
            "</script>"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertBatch(List<yian_shexiang> yianShexiangList);

    @Delete("delete from [yian_shexiang] where yianid=#{yianid}")
    public void deleteByYianId(long yianid);
}
